/*
* Configuration of module: CanTp
*
* Created by:   qinminyuan
* Copyright:    (C)  
*
* Configured for (MCU):    MCU
*
* Module vendor:           ArcCore
* Generator version:       01.00
*/
#ifdef USE_CANTP
#include "CanTp.h"
#if defined(USE_CANIF)
#include "CanIf.h"
#endif
#if defined(USE_PDUR)
#include "PduR.h"
#endif

#if defined(__WINDOWS__) || defined(__LINUX__)
#define CANTP_TIMEOUT_UNIT 10
#else
#define CANTP_TIMEOUT_UNIT 1
#endif

static const CanTp_GeneralType CanTpGeneralConfig =
{
    .main_function_period =  1,
    .number_of_sdus = 2,
	.number_of_pdus = 2,
	.padding = 0x00
};
//NSa TODO:
static const CanTp_NSaType CanTpNSaConfig =
{
    .CanTpNSa =  0,
};

static const CanTp_NTaType CanTpNTaConfig =
{
    .CanTpNTa =  0,
};

const CanTp_NSduType CanTpNSduConfigList[] =
{

    {
        .direction =  ISO15765_RECEIVE,
        .listItemType =  CANTP_NOT_LAST_ENTRY,
        .configData.CanTpRxNSdu.CanTp_FcPduId =  CANTP_ID_Phys_DiagRx,
        .configData.CanTpRxNSdu.CanIf_FcPduId =  CANIF_ID_Phys_DiagRx,
        .configData.CanTpRxNSdu.PduR_PduId =  PDUR_ID_Phys_DiagRx,
        .configData.CanTpRxNSdu.CanTpAddressingFormant =  CANTP_STANDARD,
        .configData.CanTpRxNSdu.CanTpBs =   0,
        .configData.CanTpRxNSdu.CanTpNar =  (25)*CANTP_TIMEOUT_UNIT,
        .configData.CanTpRxNSdu.CanTpNbr =  (25)*CANTP_TIMEOUT_UNIT,
        .configData.CanTpRxNSdu.CanTpNcr =  (150)*CANTP_TIMEOUT_UNIT,
        .configData.CanTpRxNSdu.CanTpRxChannel =  CANTP_ID_Phys_DiagRx,
        .configData.CanTpRxNSdu.CanTpRxDI =  8,
        .configData.CanTpRxNSdu.CanTpRxPaddingActivation =  CANTP_ON,
        .configData.CanTpRxNSdu.CanTpRxTaType =  CANTP_PHYSICAL,
        .configData.CanTpRxNSdu.CanTpWftMax =  10,
        .configData.CanTpRxNSdu.CanTpSTmin  =  0,
        .configData.CanTpRxNSdu.CanTpNSa =  &CanTpNSaConfig,
        .configData.CanTpRxNSdu.CanTpNTa =  &CanTpNTaConfig,
        .configData.CanTpRxNSdu.ll_dl =  8,
    },

    {
        .direction =  ISO15765_RECEIVE,
        .listItemType =  CANTP_NOT_LAST_ENTRY,
        .configData.CanTpRxNSdu.CanTp_FcPduId =  CANTP_ID_Func_DiagRx,
        .configData.CanTpRxNSdu.CanIf_FcPduId =  CANIF_ID_Func_DiagRx,
        .configData.CanTpRxNSdu.PduR_PduId =  PDUR_ID_Func_DiagRx,
        .configData.CanTpRxNSdu.CanTpAddressingFormant =  CANTP_STANDARD,
        .configData.CanTpRxNSdu.CanTpBs =   0,
        .configData.CanTpRxNSdu.CanTpNar =  (25)*CANTP_TIMEOUT_UNIT,
        .configData.CanTpRxNSdu.CanTpNbr =  (25)*CANTP_TIMEOUT_UNIT,
        .configData.CanTpRxNSdu.CanTpNcr =  (150)*CANTP_TIMEOUT_UNIT,
        .configData.CanTpRxNSdu.CanTpRxChannel =  CANTP_ID_Func_DiagRx,
        .configData.CanTpRxNSdu.CanTpRxDI =  8,
        .configData.CanTpRxNSdu.CanTpRxPaddingActivation =  CANTP_ON,
        .configData.CanTpRxNSdu.CanTpRxTaType =  CANTP_FUNCTION,
        .configData.CanTpRxNSdu.CanTpWftMax =  10,
        .configData.CanTpRxNSdu.CanTpSTmin  =  0,
        .configData.CanTpRxNSdu.CanTpNSa =  &CanTpNSaConfig,
        .configData.CanTpRxNSdu.CanTpNTa =  &CanTpNTaConfig,
        .configData.CanTpRxNSdu.ll_dl =  8,
    },

    {
        .direction =  IS015765_TRANSMIT,
        .listItemType =  CANTP_NOT_LAST_ENTRY,
        .configData.CanTpTxNSdu.CanTp_FcPduId =  CANTP_ID_Phys_DiagTx,
        .configData.CanTpTxNSdu.CanIf_PduId   =  CANIF_ID_Phys_DiagTx,
        .configData.CanTpTxNSdu.PduR_PduId =  PDUR_ID2_Phys_DiagTx,
        .configData.CanTpTxNSdu.CanTpAddressingMode =  CANTP_STANDARD,
        .configData.CanTpTxNSdu.CanTpNas =  (25)*CANTP_TIMEOUT_UNIT,
        .configData.CanTpTxNSdu.CanTpNbs =  (75)*CANTP_TIMEOUT_UNIT,
        .configData.CanTpTxNSdu.CanTpNcs =  (25)*CANTP_TIMEOUT_UNIT,
        .configData.CanTpTxNSdu.CanTpTxChannel =  CANIF_ID_Phys_DiagTx,
        .configData.CanTpTxNSdu.CanTpTxDI =  8,
        .configData.CanTpTxNSdu.CanTpTxPaddingActivation =  CANTP_ON,
        .configData.CanTpTxNSdu.CanTpTxTaType =  CANTP_PHYSICAL,
        .configData.CanTpTxNSdu.CanTpNSa =  &CanTpNSaConfig,
        .configData.CanTpTxNSdu.CanTpNTa =  &CanTpNTaConfig,
        .configData.CanTpTxNSdu.ll_dl =  8,
    },
};

const CanTp_RxIdType CanTp_RxIdList[] = 
{

    {
        .CanTpAddressingMode =  CANTP_STANDARD,
        .CanTpNSduIndex =  CANTP_ID_Phys_DiagRx,
        .CanTpReferringTxIndex =  CANTP_ID_Phys_DiagRx,
    },

    {
        .CanTpAddressingMode =  CANTP_STANDARD,
        .CanTpNSduIndex =  CANTP_ID_Func_DiagRx,
        .CanTpReferringTxIndex =  CANTP_ID_Func_DiagRx,
    },

    {
        .CanTpAddressingMode =  CANTP_STANDARD,
        .CanTpNSduIndex =  CANTP_ID_Phys_DiagTx,
        .CanTpReferringTxIndex =  CANTP_ID_Phys_DiagTx,
    },
};

const CanTp_ConfigType CanTpConfig =
{
    .CanTpGeneral     =      &CanTpGeneralConfig,
    .CanTpNSduList =     CanTpNSduConfigList,
    .CanTpRxIdList =    CanTp_RxIdList
};

#endif /* USE_CANTP */
